package com.ruoyi.project.module.releaseProperty.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.releaseProperty.domain.ReleaseProperty;
import com.ruoyi.project.module.releaseProperty.service.IReleasePropertyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 发布属性 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-12-06
 */
@Controller
@RequestMapping("/module/releaseProperty")
public class ReleasePropertyController extends BaseController
{
    private String prefix = "module/releaseProperty";
	
	@Autowired
	private IReleasePropertyService releasePropertyService;
	
	@RequiresPermissions("module:releaseProperty:view")
	@GetMapping()
	public String releaseProperty()
	{
	    return prefix + "/releaseProperty";
	}
	
	/**
	 * 查询发布属性列表
	 */
	@RequiresPermissions("module:releaseProperty:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ReleaseProperty releaseProperty)
	{
		startPage();
        List<ReleaseProperty> list = releasePropertyService.selectReleasePropertyList(releaseProperty);
		return getDataTable(list);
	}
	
	/**
	 * 新增发布属性
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存发布属性
	 */
	@RequiresPermissions("module:releaseProperty:add")
	@Log(title = "发布属性", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ReleaseProperty releaseProperty)
	{		
		return toAjax(releasePropertyService.insertReleaseProperty(releaseProperty));
	}

	/**
	 * 修改发布属性
	 */
	@GetMapping("/edit/{configReleasePropertyId}")
	public String edit(@PathVariable("configReleasePropertyId") Long configReleasePropertyId, ModelMap mmap)
	{
		ReleaseProperty releaseProperty = releasePropertyService.selectReleasePropertyById(configReleasePropertyId);
		mmap.put("releaseProperty", releaseProperty);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存发布属性
	 */
	@RequiresPermissions("module:releaseProperty:edit")
	@Log(title = "发布属性", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ReleaseProperty releaseProperty)
	{		
		return toAjax(releasePropertyService.updateReleaseProperty(releaseProperty));
	}
	
	/**
	 * 删除发布属性
	 */
	@RequiresPermissions("module:releaseProperty:remove")
	@Log(title = "发布属性", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(releasePropertyService.deleteReleasePropertyByIds(ids));
	}
	
}
